package com.syg.servlet03;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 生成验证码
 */
@WebServlet("/verificationCodeForm")
public class _05_VerificationCode_servlet_form extends HttpServlet{

    int access = 0;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        _04_VerificationCode_servlet verificationCodeServlet = new _04_VerificationCode_servlet();
        verificationCodeServlet.doPost(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        if(0==access){
            this.getServletContext().getRequestDispatcher("/WEB-INF/JspPage/servlet03/_05_VerificationCode_servlet_form.jsp").forward(req, resp);
            access++;
        }else{
            doPost(req,resp);
        }
    }

}